<!DOCTYPE html>
<html lang="zh-CN">
  <head>
  <meta charset="UTF-8">
  <meta 
    name="viewport"
    content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
  <meta 
    http-equiv="X-UA-Compatible" 
    content="ie=edge">
  <meta 
    name="theme-color" 
    content="#fff" 
    id="theme-color">
  <meta 
    name="description" 
    content="程序员的快乐小网站">
  <link 
    rel="icon" 
    href="https://demo.theme-kaze.top/img/Kaze.png">
  <title>计算机网络传输层（下）</title>
  
    
      <meta 
        property="og:title" 
        content="计算机网络传输层（下）">
    
    
      <meta 
        property="og:url" 
        content="http://www.baikaihua.gitee.io/2021/11/01/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C%E4%BC%A0%E8%BE%93%E5%B1%82%EF%BC%88%E4%B8%8B%EF%BC%89/index.html">
    
    
      <meta 
        property="og:img" 
        content="https://gitee.com/baikaihua/tochang/raw/master/20180420160407836.jpg">
    
    
      <meta 
        property="og:img" 
        content="&lt;p&gt;TCP协议的介绍和拥塞控制的基本原理，以及TCP协议的拥塞算法。&lt;/p&gt;
&lt;p&gt;整理：白开画&lt;/p&gt;">
    
    
      <meta 
        property="og:type" 
        content="article">
      <meta 
        property="og:article:published_time" 
        content="2021-11-01">
      <meta 
        property="og:article:modified_time" 
        content="2021-11-02">
      <meta 
        property="og:article:author" 
        content="白开画 and 徐威">
      
        
          <meta 
            property="og:article:tag" 
            content="计算机网络">
        
          <meta 
            property="og:article:tag" 
            content="网络">
        
          <meta 
            property="og:article:tag" 
            content="白开画">
        
          <meta 
            property="og:article:tag" 
            content="基础">
        
          <meta 
            property="og:article:tag" 
            content="tcp">
        
          <meta 
            property="og:article:tag" 
            content="TCP">
        
          <meta 
            property="og:article:tag" 
            content="拥塞控制">
        
      
    
  
  <script>
    function loadScript(url, cb) {
      var script = document.createElement('script');
      script.src = url;
      if (cb) script.onload = cb;
      script.async = true;
      document.body.appendChild(script);
    }
    function loadCSS(href, data, attr) {
      var sheet = document.createElement('link');
      sheet.ref = 'stylesheet';
      sheet.href = href;
      sheet.dataset[data] = attr;
      document.head.appendChild(sheet);
    }
    function changeCSS(cssFile, data, attr) {
      var oldlink = document.querySelector(data);
      var newlink = document.createElement("link");
      newlink.setAttribute("rel", "stylesheet");
      newlink.setAttribute("href", cssFile);
      newlink.dataset.prism = attr;
      document.head.replaceChild(newlink, oldlink);
    }
  </script>
  
    
  
  <script>
    // control reverse button
    var reverseDarkList = {
      dark: 'light',
      light: 'dark'
    };
    var themeColor = {
      dark: '#1c1c1e',
      light: '#fff'
    }
    // get the data of css prefers-color-scheme
    var getCssMediaQuery = function() {
      return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
    };
    // reverse current darkmode setting function
    var reverseDarkModeSetting = function() {
      var setting = localStorage.getItem('user-color-scheme');
      if(reverseDarkList[setting]) {
        setting = reverseDarkList[setting];
      } else if(setting === null) {
        setting = reverseDarkList[getCssMediaQuery()];
      } else {
        return;
      }
      localStorage.setItem('user-color-scheme', setting);
      return setting;
    };
    // apply current darkmode setting
  </script>
  
    <script>
      var setDarkmode = function(mode) {
      var setting = mode || localStorage.getItem('user-color-scheme');
      if(setting === getCssMediaQuery()) {
        document.documentElement.removeAttribute('data-user-color-scheme');
        localStorage.removeItem('user-color-scheme');
        document.getElementById('theme-color').content = themeColor[setting];
        document.getElementById('theme-color').dataset.mode = setting;
      } else if(reverseDarkList[setting]) {
        document.documentElement.setAttribute('data-user-color-scheme', setting);
        document.getElementById('theme-color').content = themeColor[setting];
        document.getElementById('theme-color').dataset.mode = setting;
      } else {
        document.documentElement.removeAttribute('data-user-color-scheme');
        localStorage.removeItem('user-color-scheme');
        document.getElementById('theme-color').content = themeColor[getCssMediaQuery()];
        document.getElementById('theme-color').dataset.mode = getCssMediaQuery();
      }
    };
    setDarkmode();
    </script>
  
  
  <link rel="preload" href="//at.alicdn.com/t/font_1946621_i1kgafibvw.css" as="style" >
  <link rel="preload" href="//at.alicdn.com/t/font_1952792_89b4ac4k4up.css" as="style" >
  
  
    <link rel="preload" href="/js/lib/lightbox/baguetteBox.min.js" as="script">
    <link rel="preload" href="/js/lib/lightbox/baguetteBox.min.css" as="style" >
  
  
    <link rel="preload" href="/js/lib/lozad.min.js" as="script">
  
  
  
  
    
    <link rel="prefetch" href="//cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" as="script">
  
  
    
    <link rel="prefetch" href="//unpkg.com/valine/dist/Valine.min.js" as="script">
  
  
  
  <link rel="stylesheet" href="/css/main.css">
  
  <link rel="stylesheet" href="//at.alicdn.com/t/font_1946621_i1kgafibvw.css">
  
  <link rel="stylesheet" href="//at.alicdn.com/t/font_1952792_89b4ac4k4up.css">
  
    <link rel="stylesheet" href="/js/lib/lightbox/baguetteBox.min.css">
  
<meta name="generator" content="Hexo 5.4.0"></head>

  <body>
    <div class="wrapper">
       
      <nav class="navbar">
  <div class="navbar-logo">
    <span class="navbar-logo-main">
      
        <img 
          class="navbar-logo-img" 
          src="https://demo.theme-kaze.top/img/Kaze.png" 
          alt="blog logo">
      
      <span class="navbar-logo-dsc">程序小站</span>
    </span>
  </div>
  <div class="navbar-menu">
    
      <a 
        href="/" 
        class="navbar-menu-item">
        
          首页
        
      </a>
    
      <a 
        href="/archives" 
        class="navbar-menu-item">
        
          归档
        
      </a>
    
      <a 
        href="/tags" 
        class="navbar-menu-item">
        
          标签
        
      </a>
    
      <a 
        href="/categories" 
        class="navbar-menu-item">
        
          分类
        
      </a>
    
      <a 
        href="/about" 
        class="navbar-menu-item">
        
          关于
        
      </a>
    
    <a 
      class="navbar-menu-item darknavbar" 
      id="dark">
      <i class="iconfont icon-weather"></i>
    </a>
    <a 
      class="navbar-menu-item searchnavbar" 
      id="search">
      <i 
        class="iconfont icon-search" 
        style="font-size: 1.2rem; font-weight: 400;">
      </i>
    </a>
  </div>
</nav> 
      
      <div 
        id="local-search" 
        style="display: none">
        <input
          class="navbar-menu-item"
          id="search-input"
          placeholder="请输入搜索内容..." />
        <div id="search-content"></div>
      </div>
      
      <div class="section-wrap">
        <div class="container">
          <div class="columns">
            <main class="main-column">
  <div class="image-wrapper">
    <img 
      src="https://gitee.com/baikaihua/tochang/raw/master/20180420160407836.jpg" 
      data-src="https://gitee.com/baikaihua/tochang/raw/master/20180420160407836.jpg"
      srcset="data:image/svg+xml,%3Csvg%20xmlns=&#39;http://www.w3.org/2000/svg&#39;%20viewBox=&#39;0%200%20300%20300&#39;%3E%3C/svg%3E"
      class="image lozad"
      alt="计算机网络传输层（下） thumbnail">
  </div>

<article class="card card-content">
  <header>
    <h1 class="post-title">
      计算机网络传输层（下）
    </h1>
  </header>
  <div class="post-meta post-show-meta">
    <time datetime="2021-11-01T09:10:01.000Z">
      <i 
        class="iconfont icon-calendar" 
        style="margin-right: 2px;">
      </i>
      <span>2021-11-01</span>
    </time>
    
      <span class="dot"></span>
      
        <a 
          href="/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/" 
          class="post-meta-link">
          计算机网络
        </a>
      
    
    
      <span class="dot"></span>
      <span>3k 字</span>
    
  </div>
  
    <div 
      class="post-meta post-show-meta" 
      style="margin-top: -10px;">
      <div style="display: flex; align-items: center;">
        <i 
          class="iconfont icon-biaoqian" 
          style="margin-right: 2px; font-size: 1.15rem;">
        </i>
        
          
          <a 
            href="/tags/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/" 
            class="post-meta-link">
            计算机网络
          </a>
        
          
            <span class="dot"></span>
          
          <a 
            href="/tags/%E7%BD%91%E7%BB%9C/" 
            class="post-meta-link">
            网络
          </a>
        
          
            <span class="dot"></span>
          
          <a 
            href="/tags/%E7%99%BD%E5%BC%80%E7%94%BB/" 
            class="post-meta-link">
            白开画
          </a>
        
          
            <span class="dot"></span>
          
          <a 
            href="/tags/%E5%9F%BA%E7%A1%80/" 
            class="post-meta-link">
            基础
          </a>
        
          
            <span class="dot"></span>
          
          <a 
            href="/tags/tcp/" 
            class="post-meta-link">
            tcp
          </a>
        
          
            <span class="dot"></span>
          
          <a 
            href="/tags/TCP/" 
            class="post-meta-link">
            TCP
          </a>
        
          
            <span class="dot"></span>
          
          <a 
            href="/tags/%E6%8B%A5%E5%A1%9E%E6%8E%A7%E5%88%B6/" 
            class="post-meta-link">
            拥塞控制
          </a>
        
      </div>
    </div>
  
  </header>
  <div 
    id="section" 
    class="post-content">
    <p>TCP协议的介绍和拥塞控制的基本原理，以及TCP协议的拥塞算法。</p>
<p>整理：白开画</p>
<span id="more"></span>
<h2 id="面向连接的传输协议"><a class="markdownIt-Anchor" href="#面向连接的传输协议"></a> 面向连接的传输协议</h2>
<h3 id="tcp概述"><a class="markdownIt-Anchor" href="#tcp概述"></a> TCP概述</h3>
<p>1.TCP的特点：</p>
<p>（1）点对点：只能有一个发送方，一个接受方。</p>
<p>（2）可靠的、按序的字节流。</p>
<p>（3）流水线机制：TCP拥塞控制和流量控制机制设置窗口尺寸。</p>
<p>（4）发送方和接受方拥有缓存。</p>
<p>（5）全双工。</p>
<p>（6）面向连接</p>
<ul>
<li>通信双方在发送数据之前必须建立连接。</li>
<li>连接状态只在连接的两端中维护，在沿途节点中并不维护状态。</li>
<li>TCP连接包括：两台主机的缓存、连接状态变量、socket等。</li>
</ul>
<p>（7）拥有链路控制机制</p>
<p>2.TCP段结构</p>
<p><img src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211026204132.jpg" alt="" / srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20300%20300'%3E%3C/svg%3E" data-src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211026204132.jpg" class="lozad post-image"></p>
<p>3.序列号和ACK</p>
<p>（1）序列号</p>
<ul>
<li>序列号指的是segment中第一个字节的编号，而不是segment的编号。</li>
<li>建立TCP连接时，双方随机选择序列号。</li>
</ul>
<p>（2）ACKs</p>
<ul>
<li>希望接受到的下一个字节的序列号。</li>
<li>累计确认：该序列号之间的所有字节均已被正确接收到。</li>
</ul>
<p><img src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211026213657.jpg" alt="" / srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20300%20300'%3E%3C/svg%3E" data-src="https://gitee.com/baikaihua/tochang/raw/master/QQ%E6%88%AA%E5%9B%BE20211026213657.jpg" class="lozad post-image"></p>
<h3 id="tcp可靠数据传输"><a class="markdownIt-Anchor" href="#tcp可靠数据传输"></a> TCP可靠数据传输</h3>
<p>1.TCP的可靠数据传输概述</p>
<p>（1）TCP在IP层提供的不可靠服务基层上实现可靠数据传输服务。</p>
<p>（2）使用流水线机制</p>
<p>（3）使用积累确认机制</p>
<p>（4）使用单一重传定时器</p>
<p>2.TCP发送方事件</p>
<p>（1）从应用层收到数据</p>
<ul>
<li>创建segment</li>
<li>序列号是segment第一个字节的编号</li>
<li>开启计时器</li>
<li>设置超时时间</li>
</ul>
<p>（2）超时</p>
<ul>
<li>重传引起超时的segment</li>
<li>重启定时器</li>
</ul>
<p>（3）收到ACK</p>
<p>​		如果确定此前未确定的segment则更新sendbase，如果窗口中还有未被确认的分组。则重新启动定时器。</p>
<p>3.快速重传机制</p>
<p>（1）通过重复ACK检测分组丢失。</p>
<p>（2）如果sender收到对同一数据的3个ACK，则假定该数据之后的段已经丢失，则在定时器超时之前即进行重传。</p>
<h3 id="tcp流量控制"><a class="markdownIt-Anchor" href="#tcp流量控制"></a> TCP流量控制</h3>
<p>​		检测buffer的剩余空间，通过回传消息告知发送方控制流量大小。</p>
<h3 id="tcp连接管理"><a class="markdownIt-Anchor" href="#tcp连接管理"></a> TCP连接管理</h3>
<p><strong>对于这一部分，我认为CSDN有一篇文章写得比较清晰，“TCP连接管理”这一段则是对CSDN上文章的转载。</strong></p>
<ol>
<li>
<p>TCP连接的建立与终止<br />
一个TCP连接是由一个四元组构成，分别是两个IP地址和两个端口号。<br />
一个TCP的连接分为3个阶段：启动，数据传输，退出。</p>
</li>
<li>
<p>TCP连接的步骤：<br />
（1）客户端发送一个SYN报文段， SYN报文段就是TCP头部中的SYN置1的报文段，在这个报文段中指明想要连接的端口号和客户端的初始序列号，通常把这个报文段称为段1.</p>
<p>​		（2）服务器端收到这个报文，发送自己的SYN报文做为响应，在这个报文中，包括服务器端的初始序列号，同时还会给客户端发送一个ACK,ACK的值为客户端的初始序列号+1，这个报文称为段2，每次发送一个SYN,序列号就会自动加1.<br />
​	 （3）客户端收到服务器端发来的SYN报文，将服务器的初始序列号+1，作为ACK,返回给服务器，这个报文称为段3<br />
发送的这三个报文，就能完成一个TCP的连接建立，称为三次握手。</p>
</li>
<li>
<p>TCP关闭步骤：<br />
连接的任何一方，都可以发起关闭操作，同时还支持双方同时关闭连接的操作。<br />
（1）连接的主动关闭者，发送一个FIN报文（TCP头部中的FIN置1的报文），希望接收者看到自己当前的序列号，还有一个ACK（确定对方最近一次发来的数据）<br />
（2）连接的被动关闭者将收到的连接主动发起者发来的当前序列号+1，作为ACK的值，返回给连接主动者。<br />
（3）被动关闭者转变为主动关闭者，发送自己的FIN报文，包括自己的报文序列号。<br />
（4）连接的主动关闭者收到连接的被动关闭者发送来的FIN报文，发送一个ACK,对收到这个报文的响应。关闭一个TCP连接，需要四个报文，称为TCP的四次握手。</p>
<p><img src="https://gitee.com/baikaihua/tochang/raw/master/20200420210256582.jpg" alt="" / srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20300%20300'%3E%3C/svg%3E" data-src="https://gitee.com/baikaihua/tochang/raw/master/20200420210256582.jpg" class="lozad post-image"></p>
</li>
<li>
<p>TCP半关闭：<br />
由于TCP的双工通信特性，TCP支持半关闭。TCP的半关闭操作是指仅关闭数据流的一个传输方向，而另一方仍在传输数据直到它被关闭为止。</p>
<p><img src="https://gitee.com/baikaihua/tochang/raw/master/2020042021021156.jpg" alt="" / srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20300%20300'%3E%3C/svg%3E" data-src="https://gitee.com/baikaihua/tochang/raw/master/2020042021021156.jpg" class="lozad post-image"></p>
</li>
<li>
<p>同时打开与关闭：<br />
假设主机A的应用程序通过本地7777端口向主机B的8888端口发送一个主动打开请求，同时，主机B的应用程序也通过本地8888端口向主机A的7777端口发送一个主动打开请求。</p>
<p><img src="https://gitee.com/baikaihua/tochang/raw/master/20200420210110842.jpg" alt="" / srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20300%20300'%3E%3C/svg%3E" data-src="https://gitee.com/baikaihua/tochang/raw/master/20200420210110842.jpg" class="lozad post-image"></p>
<p>​	一个同时打开过程需要交换四个报文段，比普通的三次握手增加了一次，由于通信双方都是客户端和服务器的角色。<br />
​	同时关闭与普通的并没有太大的区别，因为通信的一方，都可以主动的提出关闭请求，并发送首个FIN，两者最大的区别在于，同时关闭是交叉，而普通的关闭是顺时的。</p>
<p><img src="https://gitee.com/baikaihua/tochang/raw/master/20200420205805548.jpg" alt="" / srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20300%20300'%3E%3C/svg%3E" data-src="https://gitee.com/baikaihua/tochang/raw/master/20200420205805548.jpg" class="lozad post-image"></p>
</li>
<li>
<p>初始序列号：<br />
（1）在发送用于建立连接的SYN之前，通信双方会选择一个初始序列号。初始序列号会随时间而改变，因此每个连接都拥有不同的初始序列号。初始序列号可被视为一个32位的计数器，计数器的值每4微秒加1，以防止出现于其他连接的序列号重叠的情况。</p>
</li>
<li>
<p>连接建立超时<br />
在连接建立超时的时候，连接的打开方会产生指数回退行为：客户端TCP为了建立连接而频繁发送SYN报文段，首个报文段发送后3s发送第二个，第二个报文段之后6s发送第三个，第三个报文段12s后发送第四个…<br />
————————————————<br />
版权声明：本文为CSDN博主「纯粹.」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。<br />
原文链接：<a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_39346534/article/details/105644307">https://blog.csdn.net/qq_39346534/article/details/105644307</a></p>
</li>
</ol>
<h2 id="拥塞控制原理"><a class="markdownIt-Anchor" href="#拥塞控制原理"></a> 拥塞控制原理</h2>
<ol>
<li>
<p>拥塞</p>
<p>（1）非正式定义：“太多发送主机发送了太多数据或者发送速度太快，以至于网络无法处理。”</p>
<p>（2）表现：分组丢失、分组延迟过大。</p>
</li>
<li>
<p>拥塞的成因和代价</p>
<p>（1）成因1：线路带宽有限。</p>
<p>（2）代价1：拥塞时分组延迟大。</p>
<p>（3）成因2：路由缓存有限。</p>
<p>（4）代价2：需要大量的数据重传，造成网络资源浪费。</p>
</li>
<li>
<p>拥塞控制的方法</p>
<p>（1）端到端的拥塞控制：</p>
<ul>
<li>网络层不需要显示地提供支持</li>
<li>端系统通过观察loss，delay等网络行为判断是否发送拥塞</li>
<li>TCP采取这种方法</li>
</ul>
<p>（2）网络辅助的拥塞控制：</p>
<ul>
<li>路由器向发送方显示地反馈网络拥塞消息</li>
<li>简单的拥塞提示（1bit）：SNA,DECbit,TCP/IP ECN,ATM</li>
<li>提示发送方应采取何种速率</li>
</ul>
</li>
<li>
<p>ATM ABR拥塞控制</p>
<p>（1）ABR：available bit rate</p>
<ul>
<li>“弹性服务”</li>
<li>如果发送路径负载较低，则尽可能的使用带宽</li>
<li>如果发送路径拥塞，则发送方降到最低保障速率</li>
</ul>
<p>（2）RM cells：</p>
<ul>
<li>发送方发送</li>
<li>在交换机位置改变RM cell位（网络辅助），再由返回方把RM cell返回给发送方</li>
</ul>
</li>
</ol>
<h2 id="tcp拥塞控制tcp拥塞控制算法"><a class="markdownIt-Anchor" href="#tcp拥塞控制tcp拥塞控制算法"></a> TCP拥塞控制（TCP拥塞控制算法）</h2>
<h3 id="慢启动"><a class="markdownIt-Anchor" href="#慢启动"></a> 慢启动</h3>
<p>​		1.当主机开始发送数据时，如果立即把大量数据字节注入到网络，那么就有可能引起网络拥塞，因为现在并不清楚网络的负荷情况。因此，较好的方法是先探测一下，即由小到大逐渐增大发送窗口，也就是说，由小到大逐渐增大拥塞窗口数值。通常在刚刚开始发送报文段时，先把拥塞窗口 cwnd 设置为1。而在每收到一个对新的报文段的确认后，把拥塞窗口增加至原来的2倍。用这样的方法逐步增大发送方的拥塞窗口 cwnd ，可以使分组注入到网络的速率更加合理。</p>
<p>​		2.当TCP连接时，cwnd的值通常初始置为一个MSS（最大报文段大小）的较小值，初始发送速率大约为MSS/RTT。</p>
<p>​		3.在慢启动状态，cwnd的值以一个MSS开始，cwnd每当传输的报文被确定就增加1个MSS。</p>
<p>​		4.如图，这个过程每过一个RTT，发送速率就翻番。因此，TCP发送数量初始慢，但在慢启动阶段以指数增长。</p>
<p><img src="https://gitee.com/baikaihua/tochang/raw/master/qq_pic_merged_1635767176317.jpg" alt="" / srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20300%20300'%3E%3C/svg%3E" data-src="https://gitee.com/baikaihua/tochang/raw/master/qq_pic_merged_1635767176317.jpg" class="lozad post-image"></p>
<p>​		5.慢启动结束的三种方法：</p>
<p>​		（1）如果存在一个由超时指示的丢包事件（拥塞），TCP发送方将cwnd设置为1并重新楷书慢启动过程。它将下一个状态的变量的值ssthresh（慢启动阈值）设置为cwnd/2，即当检测到拥塞时将ssthresh设为拥塞窗口的一半。</p>
<p>​		（2）当检测到拥塞时ssthresh设为cwnd的值得一半，当cwnd等于ssthresh时，进入拥塞避免模式。</p>
<p>​		（3）如果检测到3个冗余的ACK，这时TCP执行一种快速重传。</p>
<p><img src="https://gitee.com/baikaihua/tochang/raw/master/qq_pic_merged_16357685165910.jpg" alt="" / srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20300%20300'%3E%3C/svg%3E" data-src="https://gitee.com/baikaihua/tochang/raw/master/qq_pic_merged_16357685165910.jpg" class="lozad post-image"></p>
<h3 id="拥塞避免"><a class="markdownIt-Anchor" href="#拥塞避免"></a> 拥塞避免</h3>
<p>​		1.一旦进入拥塞避免状态，则采用一种较为保守的方法，每个RTT只将cwnd的值增加一个MSS。</p>
<p>​		例如，如果MSS是1460字节并且cwnd是14600字节，则在一个RTT内发送10个报文段。每个到达ACK（假设每个报文段是一个ACK）增加1/10个MSS的拥塞窗口长度，以此在收到所有10个报文段的确认后，拥塞窗口的值增加一个MSS。</p>
<p>​		2.当出现超时时，cwnd的值被设置为1个MSS；当丢包事件出现时，ssthresh的值被更新为cwnd的一半。</p>
<p>​		3.AIMD（加法增大乘法减小）：</p>
<p>​		（1）乘法减小：无论在慢启动阶段还是在拥塞控制阶段，只要网络出现超时，就是将cwnd置为1，sthresh置为cwnd的一半，然后开始执行慢启动算法</p>
<p>​		（2）加法增大：当网络频发出现超时情况时，ssthresh就下降的很快，为了减少注入到网络当中的分组数，而加法增大是执行拥塞避免算法后，是拥塞窗口缓慢的增大，以防止网络过早出现拥塞。</p>
<h3 id="快重传和快速恢复状态"><a class="markdownIt-Anchor" href="#快重传和快速恢复状态"></a> 快重传和快速恢复状态</h3>
<p>​		1.快重传：</p>
<p><img src="https://gitee.com/baikaihua/tochang/raw/master/20180420155233659.jpg" alt="" / srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20300%20300'%3E%3C/svg%3E" data-src="https://gitee.com/baikaihua/tochang/raw/master/20180420155233659.jpg" class="lozad post-image"></p>
<p>​		（1）在上图中，接收方成功的接受了发送方发来的M1,M2并且分别发送了ACK，现在接收方没有收到M3，而收到了M4，显然接收方不能确认M4，因为M4是失序的报文段。如果根据可靠性传输原理接收方什么都不做，但是按照快速重传算法，在收到M4,M5等报文段的时候，不断重复的向发送方发送M2的ACK，如果接收方一连收到三个重复的ACK，那么发送方不必等待重传计时器到期，由于发送方尽早重传未被确认的报文段。</p>
<p>​		（2）对于引起TCP进入快速恢复状态的缺失报文段，对收到的ACK，cwnd的值增加一个MSS。当对丢失的报文的一个ACK到达时，TCP在降低cwnd后进入快速恢复状态。</p>
<p>​		3.快恢复：</p>
<p><img src="https://gitee.com/baikaihua/tochang/raw/master/20180420160407836.jpg" alt="" / srcset="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20300%20300'%3E%3C/svg%3E" data-src="https://gitee.com/baikaihua/tochang/raw/master/20180420160407836.jpg" class="lozad post-image"></p>
<p>​		（1）当发送方连续收到三个重复确认，执行乘法减小，ssthresh减半。</p>
<p>​		（2）由于发送方可能认为网络现在没有拥塞，因此与慢开始不同，把cwnd值设置为ssthresh减半之后的值，然后执行拥塞避免算法，线性增大cwnd。</p>

  </div>
  <div>
    
      <div 
        class="post-note note-warning copyright" 
        style="margin-top: 42px">
        <p>
          <span style="font-weight: bold;">作者：</span><a 
            target="_blank" 
            rel="nofollow noopener noreferrer" 
            href="/about">
            白开画 and 徐威
          </a>
        </p>
        <p>
          <span style="font-weight: bold;">文章链接：</span><a 
            target="_blank" 
            rel="nofollow noopener noreferrer" 
            href="http://www.baikaihua.gitee.io/2021/11/01/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C%E4%BC%A0%E8%BE%93%E5%B1%82%EF%BC%88%E4%B8%8B%EF%BC%89/index.html">
            http://www.baikaihua.gitee.io/2021/11/01/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C%E4%BC%A0%E8%BE%93%E5%B1%82%EF%BC%88%E4%B8%8B%EF%BC%89/index.html
          </a>
        </p>
        <p><span style="font-weight: bold;">版权声明：</span>本博客所有文章除特别声明外，均采用<a target="_blank" rel="noopener" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">CC BY-NC-SA 4.0 协议</a>。转载请注明出处！</p>
      </div>
    
  </div>
</article>
<div class="nav">
  
    <div class="nav-item-prev">
      <a 
        href="/2021/11/06/PHP%E6%B5%81%E7%A8%8B%E6%8E%A7%E5%88%B6%E8%AF%AD%E5%8F%A5/index.html" 
        class="nav-link">
        <i class="iconfont icon-left nav-prev-icon"></i>
        <div>
          <div class="nav-label">上一篇</div>
          
            <div class="nav-title">PHP流程控制 </div>
          
        </div>
      </a>
    </div>
  
  
    <div class="nav-item-next">
      <a 
        href="/2021/10/31/PHP%E7%BC%96%E7%A0%81%E8%A7%84%E8%8C%83/index.html" 
        class="nav-link">
        <div>
          <div class="nav-label">下一篇</div>
          
            <div class="nav-title">PHP编码规范 </div>
          
        </div>
        <i class="iconfont icon-right nav-next-icon"></i>
      </a>
    </div>
  
</div>

  <div 
    class="card card-content comment-card" 
    style="margin-top: 16px;">
    <div class="comment-card-title">评论</div>
    
  <div id="vcomments"></div>
  
  <script>
    loadScript("//unpkg.com/valine/dist/Valine.min.js");
    var oldLoadVa = window.onload;
    window.onload = function () {
      oldLoadVa && oldLoadVa();
      new Valine({
        el: '#vcomments',
        appId: 'C2ey5RzCeMGvikIpezIqS1fW-gzGzoHsz',
        appKey: 'yNj1HPpcuT4nFzgDG1hfxiwX',
        placeholder: 'Just go go',
        path: window.location.pathname,
        avatar: 'mp',
        meta: ["nick","mail","link"],
        pageSize: '10',
        lang: '',
        visitor: 'false',
        highlight: true,
        recordIP: false,
        
        
        
        enableQQ: 'false',
        requiredFields: [],
      });
    };
  </script>

  </div>

<div 
  class="card card-content toc-card" 
  id="mobiletoc">
  <div class="toc-header">
  <i 
    class="iconfont icon-menu" 
    style="padding-right: 2px;">
  </i>目录
</div>
<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%9D%A2%E5%90%91%E8%BF%9E%E6%8E%A5%E7%9A%84%E4%BC%A0%E8%BE%93%E5%8D%8F%E8%AE%AE"><span class="toc-number">1.</span> <span class="toc-text"> 面向连接的传输协议</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#tcp%E6%A6%82%E8%BF%B0"><span class="toc-number">1.1.</span> <span class="toc-text"> TCP概述</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#tcp%E5%8F%AF%E9%9D%A0%E6%95%B0%E6%8D%AE%E4%BC%A0%E8%BE%93"><span class="toc-number">1.2.</span> <span class="toc-text"> TCP可靠数据传输</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#tcp%E6%B5%81%E9%87%8F%E6%8E%A7%E5%88%B6"><span class="toc-number">1.3.</span> <span class="toc-text"> TCP流量控制</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#tcp%E8%BF%9E%E6%8E%A5%E7%AE%A1%E7%90%86"><span class="toc-number">1.4.</span> <span class="toc-text"> TCP连接管理</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%8B%A5%E5%A1%9E%E6%8E%A7%E5%88%B6%E5%8E%9F%E7%90%86"><span class="toc-number">2.</span> <span class="toc-text"> 拥塞控制原理</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#tcp%E6%8B%A5%E5%A1%9E%E6%8E%A7%E5%88%B6tcp%E6%8B%A5%E5%A1%9E%E6%8E%A7%E5%88%B6%E7%AE%97%E6%B3%95"><span class="toc-number">3.</span> <span class="toc-text"> TCP拥塞控制（TCP拥塞控制算法）</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%85%A2%E5%90%AF%E5%8A%A8"><span class="toc-number">3.1.</span> <span class="toc-text"> 慢启动</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8B%A5%E5%A1%9E%E9%81%BF%E5%85%8D"><span class="toc-number">3.2.</span> <span class="toc-text"> 拥塞避免</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%BF%AB%E9%87%8D%E4%BC%A0%E5%92%8C%E5%BF%AB%E9%80%9F%E6%81%A2%E5%A4%8D%E7%8A%B6%E6%80%81"><span class="toc-number">3.3.</span> <span class="toc-text"> 快重传和快速恢复状态</span></a></li></ol></li></ol>
</div></main>
            <aside class="left-column">
              
              <div class="card card-author">
                
  <img 
    src="https://gitee.com/baikaihua/tochang/raw/master/src=http___b-ssl.duitang.com_uploads_item_201607_07_20160707163006_EnLeG.jpeg&refer=http___b-ssl.duitang.jpg" 
    class="author-img" 
    alt="author avatar">

<p class="author-name">白开画 and 徐威</p>
<p class="author-description">欢迎！</p>
<div class="author-message">
  <a 
    class="author-posts-count" 
    href="/archives">
    <span>33</span>
    <span>文章</span>
  </a>
  <a 
    class="author-categories-count" 
    href="/categories">
    <span>11</span>
    <span>分类</span>
  </a>
  <a 
    class="author-tags-count" 
    href="/tags">
    <span>37</span>
    <span>标签</span>
  </a>
</div>

              </div>
               <div class="sticky-tablet">
  
  
    <article class="display-when-two-columns spacer">
      <div class="card card-content toc-card">
        <div class="toc-header">
  <i 
    class="iconfont icon-menu" 
    style="padding-right: 2px;">
  </i>目录
</div>
<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%9D%A2%E5%90%91%E8%BF%9E%E6%8E%A5%E7%9A%84%E4%BC%A0%E8%BE%93%E5%8D%8F%E8%AE%AE"><span class="toc-number">1.</span> <span class="toc-text"> 面向连接的传输协议</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#tcp%E6%A6%82%E8%BF%B0"><span class="toc-number">1.1.</span> <span class="toc-text"> TCP概述</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#tcp%E5%8F%AF%E9%9D%A0%E6%95%B0%E6%8D%AE%E4%BC%A0%E8%BE%93"><span class="toc-number">1.2.</span> <span class="toc-text"> TCP可靠数据传输</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#tcp%E6%B5%81%E9%87%8F%E6%8E%A7%E5%88%B6"><span class="toc-number">1.3.</span> <span class="toc-text"> TCP流量控制</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#tcp%E8%BF%9E%E6%8E%A5%E7%AE%A1%E7%90%86"><span class="toc-number">1.4.</span> <span class="toc-text"> TCP连接管理</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%8B%A5%E5%A1%9E%E6%8E%A7%E5%88%B6%E5%8E%9F%E7%90%86"><span class="toc-number">2.</span> <span class="toc-text"> 拥塞控制原理</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#tcp%E6%8B%A5%E5%A1%9E%E6%8E%A7%E5%88%B6tcp%E6%8B%A5%E5%A1%9E%E6%8E%A7%E5%88%B6%E7%AE%97%E6%B3%95"><span class="toc-number">3.</span> <span class="toc-text"> TCP拥塞控制（TCP拥塞控制算法）</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%85%A2%E5%90%AF%E5%8A%A8"><span class="toc-number">3.1.</span> <span class="toc-text"> 慢启动</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8B%A5%E5%A1%9E%E9%81%BF%E5%85%8D"><span class="toc-number">3.2.</span> <span class="toc-text"> 拥塞避免</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%BF%AB%E9%87%8D%E4%BC%A0%E5%92%8C%E5%BF%AB%E9%80%9F%E6%81%A2%E5%A4%8D%E7%8A%B6%E6%80%81"><span class="toc-number">3.3.</span> <span class="toc-text"> 快重传和快速恢复状态</span></a></li></ol></li></ol>
      </div>
    </article>
  
  
  <article class="card card-content categories-widget">
    <div class="categories-card">
  <div class="categories-header">
    <i 
      class="iconfont icon-fenlei" 
      style="padding-right: 2px;">
    </i>分类
  </div>
  <div class="categories-list">
    
      <a href="/categories/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/">
        <div class="categories-list-item">
          计算机网络
          <span class="categories-list-item-badge">5</span>
        </div>
      </a>
    
      <a href="/categories/%E6%95%B0%E6%8D%AE%E5%BA%93/">
        <div class="categories-list-item">
          数据库
          <span class="categories-list-item-badge">3</span>
        </div>
      </a>
    
      <a href="/categories/PHP/">
        <div class="categories-list-item">
          PHP
          <span class="categories-list-item-badge">14</span>
        </div>
      </a>
    
      <a href="/categories/Windows%E7%B3%BB%E7%BB%9F/">
        <div class="categories-list-item">
          Windows系统
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
      <a href="/categories/Python/">
        <div class="categories-list-item">
          Python
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
      <a href="/categories/Linux/">
        <div class="categories-list-item">
          Linux
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
      <a href="/categories/%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84%E4%B8%8E%E7%AE%97%E6%B3%95/">
        <div class="categories-list-item">
          数据结构与算法
          <span class="categories-list-item-badge">2</span>
        </div>
      </a>
    
      <a href="/categories/%E7%BD%91%E7%BB%9C/">
        <div class="categories-list-item">
          网络
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
      <a href="/categories/%E8%B7%AF%E7%94%B1%E4%BA%A4%E6%8D%A2/">
        <div class="categories-list-item">
          路由交换
          <span class="categories-list-item-badge">3</span>
        </div>
      </a>
    
      <a href="/categories/%E8%BD%AC%E8%BD%BD/">
        <div class="categories-list-item">
          转载
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
      <a href="/categories/python/">
        <div class="categories-list-item">
          python
          <span class="categories-list-item-badge">1</span>
        </div>
      </a>
    
  </div>
</div>
  </article>
  
  <article class="card card-content tags-widget">
    <div class="tags-card">
  <div class="tags-header">
    <i 
      class="iconfont icon-biaoqian" 
      style="padding-right: 2px;">
    </i>热门标签
  </div>
  <div class="tags-list">
    
      <a 
        href="/tags/%E7%99%BD%E5%BC%80%E7%94%BB/" 
        title="白开画">
        <div class="tags-list-item">白开画</div>
      </a>
    
      <a 
        href="/tags/%E5%BE%90%E5%A8%81/" 
        title="徐威">
        <div class="tags-list-item">徐威</div>
      </a>
    
      <a 
        href="/tags/PHP/" 
        title="PHP">
        <div class="tags-list-item">PHP</div>
      </a>
    
      <a 
        href="/tags/web%E8%84%9A%E6%9C%AC/" 
        title="web脚本">
        <div class="tags-list-item">web脚本</div>
      </a>
    
      <a 
        href="/tags/%E7%BD%91%E7%BB%9C/" 
        title="网络">
        <div class="tags-list-item">网络</div>
      </a>
    
      <a 
        href="/tags/%E8%AE%A1%E7%AE%97%E6%9C%BA%E7%BD%91%E7%BB%9C/" 
        title="计算机网络">
        <div class="tags-list-item">计算机网络</div>
      </a>
    
      <a 
        href="/tags/%E5%8D%8E%E4%B8%BA/" 
        title="华为">
        <div class="tags-list-item">华为</div>
      </a>
    
      <a 
        href="/tags/%E5%8D%8E%E4%B8%BA%E8%AE%A4%E8%AF%81/" 
        title="华为认证">
        <div class="tags-list-item">华为认证</div>
      </a>
    
      <a 
        href="/tags/%E8%B7%AF%E7%94%B1%E4%BA%A4%E6%8D%A2/" 
        title="路由交换">
        <div class="tags-list-item">路由交换</div>
      </a>
    
      <a 
        href="/tags/GVRP/" 
        title="GVRP">
        <div class="tags-list-item">GVRP</div>
      </a>
    
      <a 
        href="/tags/VLAN/" 
        title="VLAN">
        <div class="tags-list-item">VLAN</div>
      </a>
    
      <a 
        href="/tags/%E5%9F%BA%E7%A1%80/" 
        title="基础">
        <div class="tags-list-item">基础</div>
      </a>
    
      <a 
        href="/tags/ip/" 
        title="ip">
        <div class="tags-list-item">ip</div>
      </a>
    
      <a 
        href="/tags/%E5%A4%A7%E6%95%B0/" 
        title="大数">
        <div class="tags-list-item">大数</div>
      </a>
    
      <a 
        href="/tags/python/" 
        title="python">
        <div class="tags-list-item">python</div>
      </a>
    
      <a 
        href="/tags/%E5%91%BD%E4%BB%A4%E6%8F%90%E7%A4%BA%E7%AC%A6/" 
        title="命令提示符">
        <div class="tags-list-item">命令提示符</div>
      </a>
    
  </div>
</div>
  </article>
  
  
</div>
            </aside>
            <aside class="right-column">
              <div class="sticky-widescreen">
  
  
    <article class="card card-content toc-card">
      <div class="toc-header">
  <i 
    class="iconfont icon-menu" 
    style="padding-right: 2px;">
  </i>目录
</div>
<ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%9D%A2%E5%90%91%E8%BF%9E%E6%8E%A5%E7%9A%84%E4%BC%A0%E8%BE%93%E5%8D%8F%E8%AE%AE"><span class="toc-number">1.</span> <span class="toc-text"> 面向连接的传输协议</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#tcp%E6%A6%82%E8%BF%B0"><span class="toc-number">1.1.</span> <span class="toc-text"> TCP概述</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#tcp%E5%8F%AF%E9%9D%A0%E6%95%B0%E6%8D%AE%E4%BC%A0%E8%BE%93"><span class="toc-number">1.2.</span> <span class="toc-text"> TCP可靠数据传输</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#tcp%E6%B5%81%E9%87%8F%E6%8E%A7%E5%88%B6"><span class="toc-number">1.3.</span> <span class="toc-text"> TCP流量控制</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#tcp%E8%BF%9E%E6%8E%A5%E7%AE%A1%E7%90%86"><span class="toc-number">1.4.</span> <span class="toc-text"> TCP连接管理</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%8B%A5%E5%A1%9E%E6%8E%A7%E5%88%B6%E5%8E%9F%E7%90%86"><span class="toc-number">2.</span> <span class="toc-text"> 拥塞控制原理</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#tcp%E6%8B%A5%E5%A1%9E%E6%8E%A7%E5%88%B6tcp%E6%8B%A5%E5%A1%9E%E6%8E%A7%E5%88%B6%E7%AE%97%E6%B3%95"><span class="toc-number">3.</span> <span class="toc-text"> TCP拥塞控制（TCP拥塞控制算法）</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%85%A2%E5%90%AF%E5%8A%A8"><span class="toc-number">3.1.</span> <span class="toc-text"> 慢启动</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8B%A5%E5%A1%9E%E9%81%BF%E5%85%8D"><span class="toc-number">3.2.</span> <span class="toc-text"> 拥塞避免</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%BF%AB%E9%87%8D%E4%BC%A0%E5%92%8C%E5%BF%AB%E9%80%9F%E6%81%A2%E5%A4%8D%E7%8A%B6%E6%80%81"><span class="toc-number">3.3.</span> <span class="toc-text"> 快重传和快速恢复状态</span></a></li></ol></li></ol>
    </article>
  
  
  <article class="card card-content">
    <div class="recent-posts-card">
  <div class="recent-posts-header">
    <i 
      class="iconfont icon-wenzhang_huaban" 
      style="padding-right: 2px;">
    </i>最近文章
  </div>
  <div class="recent-posts-list">
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2021-12-13</div>
        <a href="/2021/12/13/python%E7%88%AC%E5%8F%96%E6%B7%98%E5%AE%9D%E5%95%86%E5%93%81/index.html"><div class="recent-posts-item-content">python爬取淘宝商品</div></a>
      </div>
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2021-12-13</div>
        <a href="/2021/12/13/PHP%E5%AD%97%E7%AC%A6%E4%B8%B2%E5%B8%B8%E7%94%A8%E6%93%8D%E4%BD%9C/index.html"><div class="recent-posts-item-content">PHP字符串常用操作</div></a>
      </div>
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2021-11-29</div>
        <a href="/2021/11/29/PHP%E8%AE%A4%E8%AF%86%E5%AD%97%E7%AC%A6%E4%B8%B2/index.html"><div class="recent-posts-item-content">PHP认识字符串</div></a>
      </div>
    
      <div class="recent-posts-item">
        <div class="recent-posts-item-title">2021-11-21</div>
        <a href="/2021/11/21/PHP%E5%87%BD%E6%95%B0%E7%9A%84%E5%BA%94%E7%94%A8/index.html"><div class="recent-posts-item-content">PHP函数的应用</div></a>
      </div>
    
  </div>
</div>
  </article>
  
  
</div>
            </aside>
          </div>
        </div>
      </div>
    </div>
     
    <footer class="footer">
  <div class="footer-container">
    <div>
      <div class="footer-dsc">
        <span>
          Copyright ©
          
            2021 -
          
          2021
        </span>
        &nbsp;
        <a 
          href="/" 
          class="footer-link">
          程序小站
        </a>
      </div>
    </div>

    
      <div class="footer-dsc">
        
          Powered by
          <a 
            href="https://hexo.io/" 
            class="footer-link" 
            target="_blank" 
            rel="nofollow noopener noreferrer">
            &nbsp;Hexo
          </a>
        
        
          <span>&nbsp;|&nbsp;</span>
        
        
          Theme -
          <a 
            href="https://github.com/theme-kaze" 
            class="footer-link" 
            target="_blank"
            rel="nofollow noopener noreferrer">
            &nbsp;Kaze
          </a>
        
      </div>
    
    
    
    
      <div class="footer-dsc">
        
          本站总访问量<span id="busuanzi_value_site_pv"></span>次
        
        
          <span>&nbsp;|&nbsp;</span>
        
        
          本站总访客数<span id="busuanzi_value_site_uv"></span>次
        
      </div>
      
    
</footer> 
    
  <a 
    role="button" 
    id="scrollbutton" 
    class="basebutton" 
    aria-label="回到顶部">
    <i class="iconfont icon-arrowleft button-icon"></i>
  </a>

<a 
  role="button" 
  id="menubutton" 
  class="basebutton">
  <i class="iconfont icon-menu button-icon"></i>
</a>
<a 
  role="button" 
  id="popbutton" 
  class="basebutton" 
  aria-label="控制中心">
  <i class="iconfont icon-expand button-icon"></i>
</a>
<a 
  role="button" 
  id="darkbutton" 
  class="basebutton darkwidget" 
  aria-label="夜色模式">
  <i class="iconfont icon-weather button-icon"></i>
</a>
<a 
  role="button" 
  id="searchbutton" 
  class="basebutton searchwidget" 
  aria-label="搜索">
  <i class="iconfont icon-search button-icon"></i>
</a> 
     
     
      

  
  
    
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css">

  
 
     
     
      <script>
  var addImgLayout = function () {
    var img = document.querySelectorAll('.post-content img')
    var i
    for (i = 0; i < img.length; i++) {
      var wrapper = document.createElement('a')
      wrapper.setAttribute('href', img[i].getAttribute('data-src'))
      wrapper.setAttribute('aria-label', 'illustration')
      wrapper.style.cssText =
        'width: 100%; display: flex; justify-content: center;'
      if (img[i].alt) wrapper.dataset.caption = img[i].alt
      wrapper.dataset.nolink = true
      img[i].before(wrapper)
      wrapper.append(img[i])
      var divWrap = document.createElement('div')
      divWrap.classList.add('gallery')
      wrapper.before(divWrap)
      divWrap.append(wrapper)
    }
    baguetteBox.run('.gallery')
  }
</script>
<script>
  loadScript(
    "/js/lib/lightbox/baguetteBox.min.js",
    addImgLayout
  )
</script>
 
     
     
    <script src="/js/main.js"></script> 
    
      <script> 
        loadScript('/js/lib/busuanzi.min.js') 
      </script>
     
    
      <script>
        var addLazyload = function () {
          var observer = lozad('.lozad', {
            load: function (el) {
              el.srcset = el.getAttribute('data-src')
            },
            loaded: function (el) {
              el.classList.add('loaded')
            },
          })
          observer.observe()
        }
      </script>
      <script>
        loadScript('/js/lib/lozad.min.js', addLazyload)
      </script>
     
    
    
      <script>
        setTimeout(() => {localSearch("search.json")}, 0)
      </script>
    
  </body>
</html>
